import React, {Component} from 'react';
import connect from "../hoc/connect";
import {addNum, subNum} from "../store/module/counter";

class Home extends Component {
    render() {
        const  { counter ,addNumber,subNumber} = this.props
        return (
            <div>
                {counter}

                <button onClick={()=>addNumber(2)}>addNumber</button>
                <button onClick={()=>subNumber(3)}>subNumber</button>
            </div>
        );
    }
}

const mapStateToProps = (state)=>({
    counter:state.counter.counter
})

const mapDispatchToProps = (dispatch)=>({
    addNumber(num){
        dispatch(addNum(num))
    },
    subNumber(num){
        dispatch(subNum(num))
    }
})

export default connect(mapStateToProps,mapDispatchToProps)(Home);
